package sandbox;

import java.util.HashSet;
import java.util.Set;

public class PowerSet {

	public static Set<String> computePowerSet(String s) {
		int nBits = s.length();
		StringBuilder permutation;
		Set<String> allPermutations = new HashSet<String>();
		
		for (int i = 0; i < Math.pow(2, nBits + 1); i++) {
			permutation = new StringBuilder("");
			for(int j = 0; j < nBits; j++){
				if ((i & (1 << j)) > 0)
					permutation.append(s.charAt(j));
			}
			allPermutations.add(permutation.toString());
		}
		
		return allPermutations;
	}
}
